import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import '../../assets/css/element-plus.css'
// 引入App
import App from './App.vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
// 引入图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 引入pinia
import { createPinia } from 'pinia'
import { loginFlagStore } from '../../store'
const pinia = createPinia()
//挂载函数
function createVueApp(parentElement: any) {
    const app = document.createElement('div')
    app.setAttribute('id', 'app')
    parentElement.appendChild(app)
    const appInstance = createApp(App)
    // 挂载全局Element组件
    appInstance.use(ElementPlus, { locale: zhCn, size: 'small' })
    // 挂载pinia
    appInstance.use(pinia)
    // 挂载图标
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
        appInstance.component(key, component)
    }
    // 挂载app
    appInstance.mount(app)
}

createVueApp(document.body)

// 加载store后重新赋值store的loginFlag
const store = loginFlagStore()
store.initializeLoginFlag()
